package main
import "fmt"

type Person interface {
	eat()
	sleep()
}

type Teacher struct {
	Subject string
	Name string
}

// 指针接收者
func (t *Teacher) eat() {
	fmt.Println("Teacher eat")
}

func (t *Teacher) sleep() {
	fmt.Println("Teacher sleep")
}

func main() {
	// 接口值接收对象，无法实现接口
	// var t1 Person = Teacher{
	// 	Subject: "Math",
	// 	Name: "Tom",
	// }
	// t1.eat()
	// t1.sleep()

	// 接口指针接收对象，可以实现接口
	var t2 Person = &Teacher{
		Subject: "Math",
		Name: "Tom",
	}
	t2.eat()
	t2.sleep()
}